/*
 * Copyright (c) 2017 22420103@QQ.COM 版权所有
 */
package com.lehe.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import com.lehe.dao.PayRecordDao;
import com.lehe.entry.xh.UserDto;
import com.lehe.service.impl.IndexService;

/**
 * 用户通过微信登录授权后跳转的controller
 *
 * @author 王丹
 * @since 2017-02-25
 */
@Controller
@RequestMapping("main")
public class MainController extends Basecontroller{

    @Autowired
    private IndexService indexService;
    @Autowired
    PayRecordDao payRecordDao;

    /**
     * 用户首页,查询用户信息展示
     * @param model
     * @return
     * @throws Exception 
     */
    @RequestMapping
    public String main(Model model) throws Exception{
        UserDto userDto = indexService.queryUserInfoById(getUserId());
        if(userDto.getUtype() == 0){
        	throw new Exception("当前用户不是代理");
        }
        model.addAttribute("userInfo", userDto);
        return "user/xh_user";
    }
}
